package practice_0524;

import java.util.Scanner;

public class practice05 {
    public static void main(String[] args) {
        int[][] seat = new int[9][4];
        for (int i = 0; i < seat.length; i++) {
            for (int j = 0; j < seat[0].length; j++) {
                seat[i][j] = 1;
            }
        }
        System.out.println("\t\t\t\t简单客车售票系统");
        System.out.println("\t"+seat.length + "排"+ seat[0].length + "列的大巴车开始售票");
        for (int i = 0; i < seat.length; i++) {
            for (int j = 0; j < seat[0].length; j++) {
                System.out.print(seat[i][j] + "\t\t\t");
            }
            System.out.println();
        }
        Scanner scanner = new Scanner(System.in);
        int row,col;
        boolean if_conti = true;
        while(if_conti) {
            while(true) {
                System.out.println("请输入要预定的座位行号：");
                row = scanner.nextInt();
                System.out.println("请输入要预定的座位列号：");
                col = scanner.nextInt();
                if (seat[row - 1][col - 1] == 1) {
                    seat[row - 1][col - 1] = 0;
                    break;
                } else {
                    System.out.println("这个座位已售出！请重新选择->");
                }
            }
            System.out.println("\t\t\t\t简单客车售票系统");
            System.out.println("\t" + seat.length + "排" + seat[0].length + "列的大巴车开始售票");
            for (int i = 0; i < seat.length; i++) {
                for (int j = 0; j < seat[0].length; j++) {
                    System.out.print(seat[i][j] + "\t\t\t");
                }
                System.out.println();
            }
            while(true){
                System.out.println("是否继续购票(1，继续购买 2，退出系统)");
                int flag = scanner.nextInt();
                if(flag == 2){
                    System.out.println("本次购票已结束，欢迎下次再来！");
                    if_conti = false;
                    break;
                }
                if(flag != 1){
                    System.out.println("输入错误，请重新输入!");
                }
                if(flag == 1){
                    break;
                }

            }


        }
    }
}
